﻿using System;
using Xunit;

namespace LeRenard.Core.Tests._utils_
{
    public class GetHashCodeHelperTests
    {
        public class AGivenClass
        {
            public int Id { get; set; }
            public string Name { get; set; }
            public DateTime Timestamp { get; set; }
        }

        [Fact]
        public void For_Can_Calculate_Hash()
        {
            // Arrange
            var expectedHash = ((uint)(1).GetHashCode()) / (uint)1;
            expectedHash = (expectedHash + (uint)"Name".GetHashCode()) / (uint)2;
            expectedHash = (expectedHash + (uint)DateTime.MaxValue.GetHashCode()) / (uint)3;
            var expected = (int)expectedHash;
            var @object = new AGivenClass() { Id = 1, Name = "Name", Timestamp = DateTime.MaxValue };

            // Act
            var actual = GetHashCodeHelper.For(@object.Id, @object.Name, @object.Timestamp);

            // Assert
            Assert.Equal(expected, actual);
        }
    }
}
